﻿using Ldt.DataEngine.RuleAssemble;
using System;
using System.Linq;

namespace LdtJudge.DataEngine.Common.CommHelp
{
    /// <summary>
    /// 从DocSystem站点中获取配置文件
    /// </summary>
    public static class GetConfigFile
    {
        /// <summary>
        /// 获取时间格式
        /// </summary>
        /// <param name="dataLayerStores"></param>
        /// <returns></returns>
        private static  string GetDataPaht(string SoursName,string Content)
        {
            string time = "";
            if (string.IsNullOrEmpty(SoursName) || string.IsNullOrEmpty(Content))
            {
                time = DateTime.Now.ToString("yyyy年MM月dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
            }
            else
            {
                if (SoursName.ToLower() == "mssuitbook")
                {
                    time = RuleParseClass.GetParseRegCodeList("GetSuitBookProsecutorDate", Content).FirstOrDefault(a => a != null);
                }
                else if (SoursName.ToLower() == "mscourtrecord")
                {
                    time = RuleParseClass.GetParseRegCodeList("GetCourtRecordOpenCourtDate", Content).FirstOrDefault(a => a != null);
                }
                if (string.IsNullOrEmpty(time))
                {
                    time = DateTime.Now.ToString("yyyy年MM月dd", System.Globalization.DateTimeFormatInfo.InvariantInfo);
                }
                else
                {
                    time = time.Replace(".", "/");
                }
            }
            
            return time;
        }

        /// <summary>
        /// 获取提取根路径
        /// </summary>
        /// <param name="dataLayerStores"></param>
        /// <returns></returns>
        public static string FileTextPaht(string SoursName, string Content,string CaseType,string CaseOnlyID)
        {
            string time =GetDataPaht(SoursName,Content).Replace("年", "/").Replace("月", "/").Replace("日", "");

            string[] fileList = time.Split('/');
            string filepath = "";
            filepath = fileList[0] + fileList[1] + @"\" + fileList[2] + @"\" + CaseType + @"\" + CaseOnlyID + @"\";

            return filepath;
        }
    }
}
